package org.dingfugui.triple.context;

import org.dingfugui.triple.bean.Producer;
import org.dingfugui.triple.bean.ProducerImpl;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by fugui.ding on 2015/6/11.
 */
public abstract class AbstractProducerContext extends AbstractServiceContext implements ProducerFactory {

    protected Map<String, Producer> producers = new HashMap<>();

    @Override
    public Producer getProducer(String name) {
        return producers.get(name);
    }

    @Override
    public void register(Class type, Object object) {
        if (type == null) {
            //快速失败
        }
        if (object == null) {

        }
        if (type.isInstance(object)) {
            Producer producer = new ProducerImpl(type, type.getName(), object);
            producers.put(producer.getName(), producer);
            services.put(producer.getName(), producer);
        } else {

        }
    }

}
